package dba.example.guice.dao

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.matchers.ShouldMatchers
import scala.collection.JavaConverters._
import dba.example.ExampleGuiceInjector
import dba.example.entities.Company
import dba.example.entities.Account

@RunWith(classOf[JUnitRunner])
class TestAccountDao extends ExampleGuiceInjector with ShouldMatchers {
  
  test("Test create Account") {
    val accountDao = injector.getInstance(classOf[AccountDao])
    
    val account = Account("username", "password", "name", Company(1))
    val persisted = accountDao.save(account)
    persisted.id should not be(null)
    
    account.name should equal(persisted.name)
  }
  
}